package com.dongqb.dbhelper;

import java.sql.SQLException;


public class SqliteTest {

	public void testHelper() {
		try {
			SqliteHelper h = new SqliteHelper("D:\\dongqb\\MyXlsDataMerge\\mydb.db3");
			h.executeUpdate("drop table if exists test");
			h.executeUpdate("create table test(name varchar(20))");
			h.executeUpdate("VACUUM;");//清理压缩
			/*h.executeUpdate("CREATE INDEX index_name ON test (name)");
			Date d1=new Date();
			
			List<Map<String, String>> list=new ArrayList<Map<String, String>>();
			for (int i = 0; i < 10000000; i++) {
				Map<String, String> map=new HashMap<String, String>();
				map.put("name", "record"+i);
				list.add(map);
				if (list.size()>=1000000) {
					h.executeUpdate("insert into test(name)values(?)", list, "name");
					list.clear();
				}
			}
			Date d2=new Date();
			System.out.println("耗时时间"+(d2.getTime()-d1.getTime()));
			List<Map<String, String>> sList = h.executeQuery("select name from test",
					new RowMapper<Map<String, String>>() {
						@Override
						public Map<String, String> mapRow(ResultSet rs, int index)
								throws SQLException {
							Map<String, String> map=new HashMap<String, String>();
							return map;
						}
					});
			System.out.println(sList.size());*/
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
	public static void main(String[] args) {
		SqliteTest test=new SqliteTest();
		test.testHelper();
	}
}